package org.javaforever.gatescore.vue;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import org.javaforever.gatescore.core.FrontDomain;
import org.javaforever.gatescore.core.Statement;
import org.javaforever.gatescore.core.StatementList;
import org.javaforever.gatescore.core.Writeable;
import org.javaforever.gatescore.core.WriteableUtil;

public class ElementUILoginPage extends ElementUIPage{
	private static final long serialVersionUID = -7715930714493390663L;
	protected FrontDomain domain;

	@Override
	public StatementList generateStatementList() {
		List<Writeable> sList = new ArrayList<Writeable>();
		sList.add(new Statement(1000L,0,"<template>"));
		sList.add(new Statement(2000L,1,"<div class=\"login-container\">"));
		sList.add(new Statement(3000L,2,"<el-form ref=\"loginForm\" :model=\"loginForm\" :rules=\"loginRules\" class=\"login-form\" auto-complete=\"on\" label-position=\"left\">"));
		sList.add(new Statement(4000L,3,"<div class=\"title-container\">"));
		sList.add(new Statement(5000L,4,"<h3 class=\"title\">"));
		sList.add(new Statement(6000L,5,"{{ $t('login.title') }}"));
		sList.add(new Statement(7000L,4,"</h3>"));
		sList.add(new Statement(8000L,4,"<lang-select class=\"set-language\" />"));
		sList.add(new Statement(9000L,3,"</div>"));
		sList.add(new Statement(11000L,3,"<el-form-item prop=\"username\">"));
		sList.add(new Statement(12000L,4,"<span class=\"svg-container\">"));
		sList.add(new Statement(13000L,5,"<svg-icon icon-class=\"user\" />"));
		sList.add(new Statement(14000L,4,"</span>"));
		sList.add(new Statement(15000L,4,"<el-input"));
		sList.add(new Statement(16000L,5,"v-model=\"loginForm.username\""));
		sList.add(new Statement(17000L,5,":placeholder=\"$t('login.username')\""));
		sList.add(new Statement(18000L,5,"name=\"username\""));
		sList.add(new Statement(19000L,5,"type=\"text\""));
		sList.add(new Statement(20000L,5,"auto-complete=\"on\""));
		sList.add(new Statement(21000L,4,"/>"));
		sList.add(new Statement(22000L,3,"</el-form-item>"));
		sList.add(new Statement(24000L,3,"<el-form-item prop=\"password\">"));
		sList.add(new Statement(25000L,4,"<span class=\"svg-container\">"));
		sList.add(new Statement(26000L,5,"<svg-icon icon-class=\"password\" />"));
		sList.add(new Statement(27000L,4,"</span>"));
		sList.add(new Statement(28000L,4,"<el-input"));
		sList.add(new Statement(29000L,5,"v-model=\"loginForm.password\""));
		sList.add(new Statement(30000L,5,":type=\"passwordType\""));
		sList.add(new Statement(31000L,5,":placeholder=\"$t('login.password')\""));
		sList.add(new Statement(32000L,5,"name=\"password\""));
		sList.add(new Statement(33000L,5,"auto-complete=\"on\""));
		sList.add(new Statement(34000L,5,"@keyup.enter.native=\"handleLogin\""));
		sList.add(new Statement(35000L,4,"/>"));
		sList.add(new Statement(36000L,4,"<span class=\"show-pwd\" @click=\"showPwd\">"));
		sList.add(new Statement(37000L,5,"<svg-icon :icon-class=\"passwordType === 'password' ? 'eye' : 'eye-open'\" />"));
		sList.add(new Statement(38000L,4,"</span>"));
		sList.add(new Statement(39000L,3,"</el-form-item>"));
		sList.add(new Statement(41000L,3,"<el-button :loading=\"loading\" type=\"primary\" style=\"width:48%;margin-bottom:30px;\" @click.native.prevent=\"handleLogin\">"));
		sList.add(new Statement(42000L,4,"{{ $t('login.logIn') }}"));
		sList.add(new Statement(43000L,3,"</el-button>"));
		sList.add(new Statement(45000L,3,"<el-button :loading=\"loading\" type=\"primary\" style=\"width:48%;margin-bottom:30px;\" @click.native.prevent=\"handleRegister\">"));
		sList.add(new Statement(46000L,4,"{{ $t('login.register') }}"));
		sList.add(new Statement(47000L,3,"</el-button>"));
		sList.add(new Statement(49000L,3,"<div style=\"position:relative\">"));
		sList.add(new Statement(50000L,4,"<div class=\"tips\">"));
		sList.add(new Statement(51000L,5,"<span>{{ $t('login.username') }} : admin</span>"));
		sList.add(new Statement(52000L,5,"<span>{{ $t('login.password') }} : {{ $t('login.any') }}</span>"));
		sList.add(new Statement(53000L,4,"</div>"));
		sList.add(new Statement(54000L,4,"<div class=\"tips\">"));
		sList.add(new Statement(55000L,5,"<span style=\"margin-right:18px;\">"));
		sList.add(new Statement(56000L,6,"{{ $t('login.username') }} : editor"));
		sList.add(new Statement(57000L,5,"</span>"));
		sList.add(new Statement(58000L,5,"<span>{{ $t('login.password') }} : {{ $t('login.any') }}</span>"));
		sList.add(new Statement(59000L,4,"</div>"));
		sList.add(new Statement(60000L,3,"</div>"));
		sList.add(new Statement(61000L,2,"</el-form>"));
		sList.add(new Statement(63000L,1,"</div>"));
		sList.add(new Statement(64000L,0,"</template>"));
		sList.add(new Statement(66000L,0,"<script>"));
		sList.add(new Statement(67000L,0,"import { validUsername } from '@/utils/validate'"));
		sList.add(new Statement(68000L,0,"import LangSelect from '@/components/LangSelect'"));
		sList.add(new Statement(69000L,0,"import SocialSign from './socialsignin'"));
		sList.add(new Statement(70000L,0,""));
		sList.add(new Statement(71000L,0,"export default {"));
		sList.add(new Statement(72000L,1,"name: 'Login',"));
		sList.add(new Statement(73000L,1,"components: { LangSelect, SocialSign },"));
		sList.add(new Statement(74000L,1,"data() {"));
		sList.add(new Statement(75000L,2,"const validateUsername = (rule, value, callback) => {"));
		sList.add(new Statement(76000L,3,"if (!validUsername(value)) {"));
		sList.add(new Statement(77000L,4,"callback(new Error('Please enter the correct user name'))"));
		sList.add(new Statement(78000L,3,"} else {"));
		sList.add(new Statement(79000L,4,"callback()"));
		sList.add(new Statement(80000L,3,"}"));
		sList.add(new Statement(81000L,2,"}"));
		sList.add(new Statement(82000L,2,"const validatePassword = (rule, value, callback) => {"));
		sList.add(new Statement(83000L,3,"if (value.length < 4) {"));
		sList.add(new Statement(84000L,4,"callback(new Error('The password can not be less than 4 digits'))"));
		sList.add(new Statement(85000L,3,"} else {"));
		sList.add(new Statement(86000L,4,"callback()"));
		sList.add(new Statement(87000L,3,"}"));
		sList.add(new Statement(88000L,2,"}"));
		sList.add(new Statement(89000L,2,"return {"));
		sList.add(new Statement(90000L,3,"loginForm: {"));
		sList.add(new Statement(91000L,4,"username: 'admin',"));
		sList.add(new Statement(92000L,4,"password: 'admin'"));
		sList.add(new Statement(93000L,3,"},"));
		sList.add(new Statement(94000L,3,"loginRules: {"));
		sList.add(new Statement(95000L,4,"username: [{ required: true, trigger: 'blur', validator: validateUsername }],"));
		sList.add(new Statement(96000L,4,"password: [{ required: true, trigger: 'blur', validator: validatePassword }]"));
		sList.add(new Statement(97000L,3,"},"));
		sList.add(new Statement(98000L,3,"passwordType: 'password',"));
		sList.add(new Statement(99000L,3,"loading: false,"));
		sList.add(new Statement(100000L,3,"showDialog: false,"));
		sList.add(new Statement(101000L,3,"redirect: undefined"));
		sList.add(new Statement(102000L,2,"}"));
		sList.add(new Statement(103000L,1,"},"));
		sList.add(new Statement(104000L,1,"watch: {"));
		sList.add(new Statement(105000L,2,"$route: {"));
		sList.add(new Statement(106000L,3,"handler: function(route) {"));
		sList.add(new Statement(107000L,4,"this.redirect = route.query && route.query.redirect"));
		sList.add(new Statement(108000L,3,"},"));
		sList.add(new Statement(109000L,3,"immediate: true"));
		sList.add(new Statement(110000L,2,"}"));
		sList.add(new Statement(111000L,1,"},"));
		sList.add(new Statement(112000L,1,"created() {"));
		sList.add(new Statement(113000L,2,"// window.addEventListener('hashchange', this.afterQRScan)"));
		sList.add(new Statement(114000L,1,"},"));
		sList.add(new Statement(115000L,1,"destroyed() {"));
		sList.add(new Statement(116000L,2,"// window.removeEventListener('hashchange', this.afterQRScan)"));
		sList.add(new Statement(117000L,1,"},"));
		sList.add(new Statement(118000L,1,"methods: {"));
		sList.add(new Statement(119000L,2,"showPwd() {"));
		sList.add(new Statement(120000L,3,"if (this.passwordType === 'password') {"));
		sList.add(new Statement(121000L,4,"this.passwordType = ''"));
		sList.add(new Statement(122000L,3,"} else {"));
		sList.add(new Statement(123000L,4,"this.passwordType = 'password'"));
		sList.add(new Statement(124000L,3,"}"));
		sList.add(new Statement(125000L,2,"},"));
		sList.add(new Statement(126000L,2,"handleRegister() {"));
		sList.add(new Statement(127000L,3,"this.$router.push({ path: '/register' })"));
		sList.add(new Statement(128000L,2,"},"));
		sList.add(new Statement(129000L,2,"handleLogin() {"));
		sList.add(new Statement(130000L,3,"this.$refs.loginForm.validate(valid => {"));
		sList.add(new Statement(131000L,4,"if (valid) {"));
		sList.add(new Statement(132000L,5,"this.loading = true"));
		sList.add(new Statement(133000L,5,"this.$store.dispatch('LoginByUsername', this.loginForm).then((data) => {"));
		sList.add(new Statement(134000L,6,"this.loading = false"));
		sList.add(new Statement(137000L,6,"if (data.success === true) {"));
		sList.add(new Statement(139000L,7,"this.$router.push({ path: this.redirect || '/' })"));
		sList.add(new Statement(140000L,6,"} else {"));
		if ("english".equalsIgnoreCase(this.domain.getLanguage())) {
			sList.add(new Statement(141000L,7,"this.$message.error('Account or password is wrong!')"));
		}else {
			sList.add(new Statement(141000L,7,"this.$message.error('账号/密码错误')"));
		}
		sList.add(new Statement(142000L,6,"}"));
		sList.add(new Statement(143000L,5,"}).catch(() => {"));
		sList.add(new Statement(144000L,6,"this.loading = false"));
		sList.add(new Statement(145000L,5,"})"));
		sList.add(new Statement(146000L,4,"} else {"));
		sList.add(new Statement(147000L,5,"console.log('error submit!!')"));
		sList.add(new Statement(148000L,5,"return false"));
		sList.add(new Statement(149000L,4,"}"));
		sList.add(new Statement(150000L,3,"})"));
		sList.add(new Statement(151000L,2,"},"));
		sList.add(new Statement(152000L,2,"afterQRScan() {"));
		sList.add(new Statement(153000L,3,"// const hash = window.location.hash.slice(1)"));
		sList.add(new Statement(154000L,3,"// const hashObj = getQueryObject(hash)"));
		sList.add(new Statement(155000L,3,"// const originUrl = window.location.origin"));
		sList.add(new Statement(156000L,3,"// history.replaceState({}, '', originUrl)"));
		sList.add(new Statement(157000L,3,"// const codeMap = {"));
		sList.add(new Statement(158000L,3,"//   wechat: 'code',"));
		sList.add(new Statement(159000L,3,"//   tencent: 'code'"));
		sList.add(new Statement(160000L,3,"// }"));
		sList.add(new Statement(161000L,3,"// const codeName = hashObj[codeMap[this.auth_type]]"));
		sList.add(new Statement(162000L,3,"// if (!codeName) {"));
		sList.add(new Statement(163000L,3,"//   alert('第三方登录失败')"));
		sList.add(new Statement(164000L,3,"// } else {"));
		sList.add(new Statement(165000L,3,"//   this.$store.dispatch('LoginByThirdparty', codeName).then(() => {"));
		sList.add(new Statement(166000L,3,"//     this.$router.push({ path: '/' })"));
		sList.add(new Statement(167000L,3,"//   })"));
		sList.add(new Statement(168000L,3,"// }"));
		sList.add(new Statement(169000L,2,"}"));
		sList.add(new Statement(170000L,1,"}"));
		sList.add(new Statement(171000L,0,"}"));
		sList.add(new Statement(172000L,0,"</script>"));
		sList.add(new Statement(173000L,0,""));
		sList.add(new Statement(174000L,0,"<style rel=\"stylesheet/scss\" lang=\"scss\">"));
		sList.add(new Statement(175000L,0,"/* 修复input 背景不协调 和光标变色 */"));
		sList.add(new Statement(176000L,0,"/* Detail see https://github.com/PanJiaChen/vue-element-admin/pull/927 */"));
		sList.add(new Statement(177000L,0,""));
		sList.add(new Statement(178000L,0,"$bg:#283443;"));
		sList.add(new Statement(179000L,0,"$light_gray:#eee;"));
		sList.add(new Statement(180000L,0,"$cursor: #fff;"));
		sList.add(new Statement(181000L,0,""));
		sList.add(new Statement(182000L,0,"@supports (-webkit-mask: none) and (not (cater-color: $cursor)) {"));
		sList.add(new Statement(183000L,1,".login-container .el-input input{"));
		sList.add(new Statement(184000L,1,"color: $cursor;"));
		sList.add(new Statement(185000L,1,"&::first-line {"));
		sList.add(new Statement(186000L,2,"color: $light_gray;"));
		sList.add(new Statement(187000L,1,"}"));
		sList.add(new Statement(188000L,1,"}"));
		sList.add(new Statement(189000L,0,"}"));
		sList.add(new Statement(190000L,0,""));
		sList.add(new Statement(191000L,0,"/* reset element-ui css */"));
		sList.add(new Statement(192000L,0,".login-container {"));
		sList.add(new Statement(193000L,1,".el-input {"));
		sList.add(new Statement(194000L,1,"display: inline-block;"));
		sList.add(new Statement(195000L,1,"height: 47px;"));
		sList.add(new Statement(196000L,1,"width: 85%;"));
		sList.add(new Statement(197000L,1,"input {"));
		sList.add(new Statement(198000L,2,"background: transparent;"));
		sList.add(new Statement(199000L,2,"border: 0px;"));
		sList.add(new Statement(200000L,2,"-webkit-appearance: none;"));
		sList.add(new Statement(201000L,2,"border-radius: 0px;"));
		sList.add(new Statement(202000L,2,"padding: 12px 5px 12px 15px;"));
		sList.add(new Statement(203000L,2,"color: $light_gray;"));
		sList.add(new Statement(204000L,2,"height: 47px;"));
		sList.add(new Statement(205000L,2,"caret-color: $cursor;"));
		sList.add(new Statement(206000L,2,"&:-webkit-autofill {"));
		sList.add(new Statement(207000L,2,"-webkit-box-shadow: 0 0 0px 1000px $bg inset !important;"));
		sList.add(new Statement(208000L,2,"-webkit-text-fill-color: $cursor !important;"));
		sList.add(new Statement(209000L,2,"}"));
		sList.add(new Statement(210000L,1,"}"));
		sList.add(new Statement(211000L,1,"}"));
		sList.add(new Statement(212000L,1,".el-form-item {"));
		sList.add(new Statement(213000L,1,"border: 1px solid rgba(255, 255, 255, 0.1);"));
		sList.add(new Statement(214000L,1,"background: rgba(0, 0, 0, 0.1);"));
		sList.add(new Statement(215000L,1,"border-radius: 5px;"));
		sList.add(new Statement(216000L,1,"color: #454545;"));
		sList.add(new Statement(217000L,1,"}"));
		sList.add(new Statement(218000L,0,"}"));
		sList.add(new Statement(219000L,0,"</style>"));
		sList.add(new Statement(220000L,0,""));
		sList.add(new Statement(221000L,0,"<style rel=\"stylesheet/scss\" lang=\"scss\" scoped>"));
		sList.add(new Statement(222000L,0,"$bg:#2d3a4b;"));
		sList.add(new Statement(223000L,0,"$dark_gray:#889aa4;"));
		sList.add(new Statement(224000L,0,"$light_gray:#eee;"));
		sList.add(new Statement(225000L,0,""));
		sList.add(new Statement(226000L,0,".login-container {"));
		sList.add(new Statement(227000L,0,"min-height: 100%;"));
		sList.add(new Statement(228000L,0,"width: 100%;"));
		sList.add(new Statement(229000L,0,"background-color: $bg;"));
		sList.add(new Statement(230000L,0,"overflow: hidden;"));
		sList.add(new Statement(231000L,0,".login-form {"));
		sList.add(new Statement(232000L,1,"position: relative;"));
		sList.add(new Statement(233000L,1,"width: 520px;"));
		sList.add(new Statement(234000L,1,"max-width: 100%;"));
		sList.add(new Statement(235000L,1,"padding: 160px 35px 0;"));
		sList.add(new Statement(236000L,1,"margin: 0 auto;"));
		sList.add(new Statement(237000L,1,"overflow: hidden;"));
		sList.add(new Statement(238000L,0,"}"));
		sList.add(new Statement(239000L,0,".tips {"));
		sList.add(new Statement(240000L,1,"font-size: 14px;"));
		sList.add(new Statement(241000L,1,"color: #fff;"));
		sList.add(new Statement(242000L,1,"margin-bottom: 10px;"));
		sList.add(new Statement(243000L,1,"span {"));
		sList.add(new Statement(244000L,1,"&:first-of-type {"));
		sList.add(new Statement(245000L,2,"margin-right: 16px;"));
		sList.add(new Statement(246000L,1,"}"));
		sList.add(new Statement(247000L,1,"}"));
		sList.add(new Statement(248000L,0,"}"));
		sList.add(new Statement(249000L,0,".svg-container {"));
		sList.add(new Statement(250000L,1,"padding: 6px 5px 6px 15px;"));
		sList.add(new Statement(251000L,1,"color: $dark_gray;"));
		sList.add(new Statement(252000L,1,"vertical-align: middle;"));
		sList.add(new Statement(253000L,1,"width: 30px;"));
		sList.add(new Statement(254000L,1,"display: inline-block;"));
		sList.add(new Statement(255000L,0,"}"));
		sList.add(new Statement(256000L,0,".title-container {"));
		sList.add(new Statement(257000L,1,"position: relative;"));
		sList.add(new Statement(258000L,1,".title {"));
		sList.add(new Statement(259000L,1,"font-size: 26px;"));
		sList.add(new Statement(260000L,1,"color: $light_gray;"));
		sList.add(new Statement(261000L,1,"margin: 0px auto 40px auto;"));
		sList.add(new Statement(262000L,1,"text-align: center;"));
		sList.add(new Statement(263000L,1,"font-weight: bold;"));
		sList.add(new Statement(264000L,1,"}"));
		sList.add(new Statement(265000L,1,".set-language {"));
		sList.add(new Statement(266000L,1,"color: #fff;"));
		sList.add(new Statement(267000L,1,"position: absolute;"));
		sList.add(new Statement(268000L,1,"top: 3px;"));
		sList.add(new Statement(269000L,1,"font-size:18px;"));
		sList.add(new Statement(270000L,1,"right: 0px;"));
		sList.add(new Statement(271000L,1,"cursor: pointer;"));
		sList.add(new Statement(272000L,1,"}"));
		sList.add(new Statement(273000L,0,"}"));
		sList.add(new Statement(274000L,0,".show-pwd {"));
		sList.add(new Statement(275000L,1,"position: absolute;"));
		sList.add(new Statement(276000L,1,"right: 10px;"));
		sList.add(new Statement(277000L,1,"top: 7px;"));
		sList.add(new Statement(278000L,1,"font-size: 16px;"));
		sList.add(new Statement(279000L,1,"color: $dark_gray;"));
		sList.add(new Statement(280000L,1,"cursor: pointer;"));
		sList.add(new Statement(281000L,1,"user-select: none;"));
		sList.add(new Statement(282000L,0,"}"));
		sList.add(new Statement(283000L,0,".thirdparty-button {"));
		sList.add(new Statement(284000L,1,"position: absolute;"));
		sList.add(new Statement(285000L,1,"right: 0;"));
		sList.add(new Statement(286000L,1,"bottom: 6px;"));
		sList.add(new Statement(287000L,0,"}"));
		sList.add(new Statement(288000L,0,"}"));
		sList.add(new Statement(289000L,0,"</style>"));

		return WriteableUtil.merge(sList);
	}

	public FrontDomain getDomain() {
		return domain;
	}

	public void setDomain(FrontDomain domain) {
		this.domain = domain;
	}
}
